
import React, { Component } from 'react';
import eventBus from '../../../utils/eventBus';
import myPubSub from '../../../utils/myPubSub';

export default class index extends Component {

  componentDidMount(){
    console.log("componentDidMount");
    eventBus.$on("chuan",function(str){
      console.log("chuan事件被触发了 1",str);
    });
    // 绑定事件
    eventBus.$on("chuan",function(str){
      console.log("chuan事件被触发了 2",str);
    });

    // 订阅
    myPubSub.subscribe("chuanB",function(str){
      console.log("chuanB事件被触发了1",str);
    })
    myPubSub.subscribe("chuanB",function(str){
      console.log("chuanB事件被触发了2",str);
    })
    
  }

  render() {
    return (
      <div>
        <h1>子组件B</h1>
      </div>
    )
  }
}
